<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/layui.css">
</head>
<body>
<div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <header style="height: 100%">
            <div align="left">
                  <div class="layui-tab">
                          <ul class="layui-tab-title">
                            <a href="touchList.html"><li class="layui-this">开通导购</li></a>
                            <a href="orderList.html"><li>导购订单</li></a>
                            </ul>
                        </div>
                <table style="width: 100%">
                    <tr>
                        <td>
                            <form class="form-inline" onsubmit="return false">
                            <div>
                                <div class="form-group" style="float: left">
                                    查找会员:
                                    <input id="name" type="text" class="form-control" placeholder="查找会员">
                                    <button  class="layui-btn layui-btn-normal" id="open">开通导购
                                    </button>
                                </div>
                                <div class="form-group" style="float: left;margin-left: auto">
                                   <p>已授权列表(剩余授权名额:<span id="invNumber"></span>)</p>
                                </div>
                                </div>
                            </form>
                        </td>
                    </tr>
                </table>
            </div>
        </header>
        <div>
            <div class="widget-body no-padding">
                <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                    <thead>
                    <tr>
                    </tr>
                    <tr>
                        <th style="width: 20%">用户名</th>
                        <th style="width: 20%">头像</th>
                        <th style="width: 20%">手机号</th>
                        <th style="width: 20%">注册时间</th>
                        <th style="width: 20%">授权时间</th>
                        <th style="width: 10%">授权人</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/my/permission.js"></script>
<script>
$("#open").on("click", function() {
    layer.open({
        type : 2,
        title : '查找会员',
        area : [ '600px', '600px' ],
        fix : false, //
        content : 'usersList.html',
    });
});
</script>
<script type="text/javascript">
number();
function number(){
    $.ajax({
               dataType: 'json',
               type: 'post',
               url: '/clyjUser/getuser',
               async:true,
                 success: function (data) {
                   $('#invNumber').html(data.invNumber);
                 }
               });
}
   //注意:选项卡 依赖 element 模块,否则无法进行功能性操作
     layui.use('element', function(){
     var element = layui.element;
            });
    var pers = checkPermission();

    var example;

    function init() {
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide": true,
                "language": {
                    "url": "/global/js/plugin/datatables/Chinese.lang"
                },
                "ajax": {
                    "url": "/clyjUserTouch/getTouch",
                    "type": "get",
                    "data": function (d) {
                    },
                    "error": function (xhr, textStatus, errorThrown) {
                        var msg = xhr.responseText;
                        console.log(msg);
                        var response = JSON.parse(msg);
                        var code = response.code;
                        var message = response.message;
                        if (code == 400) {
                            layer.msg(message);
                        } else if (code == 401) {
                            localStorage.removeItem("token");
                            layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
                                location.href = '/login.html';
                            });
                        } else if (code == 403) {
                            console.log("未授权:" + message);
                            layer.msg('未授权');
                        } else if (code == 500) {
                            layer.msg('系统错误:' + message);
                        }
                    }
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                    {"data": "username", "defaultContent": ""},
                    {"data": "photo","defaultContent": "",
                    "render":function(data) {
                              if(data==null || data==""){
                              return data;
                              }else {
                              return "<img style='width: 50px;height: 50px' src='" + data + "' />";}
                                                            }},
                    {"data": "phone", "defaultContent": ""},
                    {"data": "createTime", "defaultContent": "",
                                       "render":function(data) {
                                           if(data==null || data==""){
                                               return data;
                                           }
                                         var dateee = new Date(data).toJSON();
                                         var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                                         data=date
                                         return data;
                                       }},
                                       {"data": "ctime", "defaultContent": "",
                                       "render":function(data) {
                                            if(data==null || data==""){
                                                 return data;
                                             }
                                            var dateee = new Date(data).toJSON();
                                            var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                                               data=date
                                             return data;}},
                                              {"data": "userPId","defaultContent": ""},

                ],
                "order": [[2, "desc"]]
            });
    }

    layui.use('layer', function () {
        var layer = layui.layer;
    });

    init();
</script>